<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网页换肤</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background: url(./1.jpg) no-repeat;
        }

        .box {
            text-align: center;
            padding: 50px 0;
            background-color: rgba(255, 255, 255, 0.4);
        }

        .box>img {
            /* 鼠标变成小手 */
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div class="box">
        <img src="./1.jpg" alt="" width="150">
        <img src="./2.jpg" alt="" width="150">
        <img src="./3.jpg" alt="" width="150">
        <img src="./4.jpg" alt="" width="150">
        <img src="./5.jpg" alt="" width="150">
    </div>
    <script>
        window.onload = function () {
            var imgs = document.querySelectorAll("img")
            imgs.forEach((item, index) => {
                item.onclick = function () {
                    document.body.style.background = 'url(./' + (index + 1) + '.jpg)'
                }
            })

        }
    </script>
</body>

</html>